﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CourseUtils;

namespace lb3
{
    public class Program
    {
       
        public static void Main(string[] args)
        {
             
            double number = IOHelpers.ReadIntFromConsole("Введите число", 0, 1000);
            double result=FindMax(number);
            Console.WriteLine("Максимальный делитель {0}",result);

            
            Console.ReadKey();
        }

          public static double FindMax(double number)
        {
            List<double> divList = new List<double>();
            for (int i = 1; i < number; i++)
            {
                double div = number / i;
                if (IsInt(div))
                {
                    Console.WriteLine(i);
                    divList.Add(i);
                }

            }
              return divList.Max();
        }

        private static bool IsInt(object value)
        {
           return Convert.ToInt32(value) == Convert.ToDouble(value);
       }
    }
}
